﻿<UserControl x:Class="ToDoList.Views.ToDoListItemView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:SampleData="clr-namespace:ToDoList.SampleData" xmlns:Converters="clr-namespace:ToDoList.Converters"
             mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <Converters:TaskToBrushConverter x:Key="TaskToBrush"/>
    </UserControl.Resources>
    <Border d:DataContext="{d:DesignInstance SampleData:DesignToDoListItemViewModel, IsDesignTimeCreatable=True}"
            CornerRadius="5"
        Height="220"
        Width="180" Background="{StaticResource DarkControlBackgroundBrush}"
        BorderBrush="{Binding Path=Task,Converter={StaticResource TaskToBrush}}" BorderThickness="3">
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"              
              ToolTipService.ToolTip="{Binding ToolTip}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>  
            <HyperlinkButton NavigateUri="{Binding Task.Link}" TargetName="_blank">
                <HyperlinkButton.Content>
                    <TextBlock Text="{Binding Task.Title}" 
                               Cursor="Hand"
                               ToolTipService.ToolTip="{Binding Task.Link}"
                               Style="{StaticResource Heading4}" Margin="10" TextTrimming="WordEllipsis"
                       TextWrapping="NoWrap"/>
                </HyperlinkButton.Content>
            </HyperlinkButton>                      
            <StackPanel Grid.Row="1" Orientation="Horizontal">
                <TextBlock Text="{Binding DateLabel}"/>
                <TextBlock Text="{Binding KeyDate, StringFormat=M/dd/yyyy}"/>                
            </StackPanel>
            <Button Grid.Row="2"  Style="{StaticResource GreenButton}" 
                    ToolTipService.ToolTip="Mark Complete"
                    Command="{Binding MarkCompleteCommand}">
                <Button.Content>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/ToDoList;component/Assets/check.png" Width="24" Height="24"/>
                            <TextBlock Text="Mark Complete"/>
                        </StackPanel>
                    </Button.Content>
            </Button>
            <StackPanel Grid.Row="3" 
                        Orientation="Horizontal"
                        HorizontalAlignment="Center" Grid.RowSpan="2">
                <Button  Style="{StaticResource OrangeButton}"
                         ToolTipService.ToolTip="Edit"
                    Command="{Binding EditCommand}">
                    <Button.Content>
                        <Image Source="/ToDoList;component/Assets/edit.png" Width="30" Height="30"/>
                    </Button.Content>
                </Button>
                <Button  Style="{StaticResource OrangeButton}"  
                         ToolTipService.ToolTip="Delete"
                    Command="{Binding DeleteCommand}">
                <Button.Content>
                    <Image Source="/ToDoList;component/Assets/delete.png" Width="30" Height="30"/>
                </Button.Content>
            </Button>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
